package com.whfc.ms.api.fvs.controller;

import com.whfc.common.result.PageData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.fuum.entity.SysUser;
import com.whfc.fvs.dto.FvsSnapshotDTO;
import com.whfc.ms.api.fvs.service.MsFvsSnapshotService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021-02-24 16:44
 */
@RequiresPermissions("fvs/log")
@RequestMapping("/ms/api/fvs/snapshot")
@RestController
public class FvsSnapshotController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MsFvsSnapshotService msFvsSnapshotService;

    @GetMapping("/list")
    public Result list(@SessionAttribute(SessionAttr.MS_USER) SysUser user,
                       @RequestParam("deptId") Integer deptId,
                       @RequestParam("pageNum") Integer pageNum,
                       @RequestParam("pageSize") Integer pageSize,
                       @RequestParam(value = "startDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
                       @RequestParam(value = "endDate", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
                       @RequestParam(value = "keyword", required = false) String keyword) {
        logger.info("获取抓拍图片列表：loginer:{},deptId:{},pageNum:{},pageSize:{},startDate:{},endDate:{},keyword:{}",
                user.getUsername(), deptId, pageNum, pageSize, startDate, endDate, keyword);
        PageData<FvsSnapshotDTO> pageData = msFvsSnapshotService.list(deptId, pageNum, pageSize, startDate, endDate, keyword);
        return ResultUtil.success(pageData);
    }
}
